package io.openmessaging;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class 组合 {

    public static void main(String[] args) {
        int[] nums=new int[]{1,2,3,4};
        List<List<Integer>> result=new ArrayList<>();
        adapter(result,new LinkedList<>(),nums,0);
        System.out.println(result);
    }


    public static void adapter(List<List<Integer>> result,LinkedList<Integer> trace,int[] nums,int first){
        if(trace.size()==3){
            result.add(new ArrayList(trace));
            return ;
        }
        for(int i=first;i<nums.length;i++){
            if (trace.contains(nums[i])){
                continue;
            }else
            {
                first++;
            }
            trace.addLast(nums[i]);
            adapter(result,trace,nums,first);
            trace.removeLast();
        }


    }
}
